package com.d3works.apps.base.rest.common;

import java.util.Collection;
import java.util.Iterator;
import org.apache.commons.collections.CollectionUtils;

/**
 * 字符串处理类
 *
 * @author wang
 */
public class S {

  public static String join(Collection<?> coll, String joiner) {
    if (CollectionUtils.isEmpty(coll)) {
      return "";
    }
    StringBuffer sb = new StringBuffer();
    Iterator<?> ite = coll.iterator();
    if (ite.hasNext()) {
      Object o = ite.next();
      sb.append(o == null ? "" : o.toString());
    }
    while (ite.hasNext()) {
      Object o = ite.next();
      sb.append(joiner);
      sb.append(o == null ? "" : o.toString());
    }
    return sb.toString();
  }
}
